﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SimpleScrum.Areas.Scrum.Models;
using SimpleScrum.Core.Entities;
using SimpleScrum.Utils;

namespace SimpleScrum.Areas.Scrum.Controllers
{
    public class InitializeController : Controller
    {
        public UsersModel ObjUsers;
        public OrganizationModel ObjOrganization;
        public ProjectModel ObjProject;

        public InitializeController()
        {
            ObjUsers = new UsersModel();
            ObjOrganization = new OrganizationModel();
            ObjProject = new ProjectModel();
        }
        //
        // GET: /Scrum/Initialize/

        public ActionResult Index()
        {

            if (Client.Instance.DefaultProjectId == Guid.Empty)
            {
                return View();
            }
            else
            {
                return RedirectToAction("Index", "DashBoard");
            }
            
        }
        public ActionResult SetAsDefaultProject(Guid id)
        {
            Users user = ObjUsers.GetUsersById(Client.Instance.ClientId);
            user.DefaultProject = ObjProject.GetProjectById(id);
            ObjUsers.UpdateUsers(user);
            Client.Instance.CurrentProjectId = id;
            Client.Instance.DefaultProjectId = id;
            return RedirectToAction("Index", "DashBoard");
        }

    }
}
